package web;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.faces.model.ListDataModel;
import javax.inject.Inject;

import facade.LeagueFacade;
import facade.dto.LeagueDTO;

@ManagedBean
@ViewScoped
public class LeagueBean {

	@Inject
	private LeagueFacade leagueService;
	
	private ListDataModel<LeagueDTO> model;
	
	private LeagueDTO newLeague = new LeagueDTO();
	private LeagueDTO leagueToDelete = null;
	
	/**
	 * Default constructor
	 */
	public LeagueBean() {
		// do nothing
	}
	
	/**
	 * Pre render view
	 */
	public void init(ComponentSystemEvent event) {
		model = new ListDataModel<LeagueDTO>(leagueService.getAllLeagues());
	}
	
	/**
	 * Add a league
	 */
	public void add() {
		;
	}
	
	/**
	 * Delete a league
	 */
	public void remove() {
		;
	}

	public ListDataModel<LeagueDTO> getModel() {
		return model;
	}

	public LeagueDTO getLeagueToDelete() {
		return leagueToDelete;
	}

	public void setLeagueToDelete(LeagueDTO leagueToDelete) {
		this.leagueToDelete = leagueToDelete;
	}

	public LeagueDTO getNewLeague() {
		return newLeague;
	}

	public void setNewLeague(LeagueDTO newLeague) {
		this.newLeague = newLeague;
	}
}
